package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YxxSanitation;
import com.ruoyi.system.service.IYxxSanitationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卫生检查记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/system/sanitation")
public class YxxSanitationController extends BaseController
{
    @Autowired
    private IYxxSanitationService yxxSanitationService;

    /**
     * 查询卫生检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:sanitation:list')")
    @GetMapping("/list")
    public TableDataInfo list(YxxSanitation yxxSanitation)
    {
        startPage();
        List<YxxSanitation> list = yxxSanitationService.selectYxxSanitationList(yxxSanitation);
        return getDataTable(list);
    }

    /**
     * 导出卫生检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:sanitation:export')")
    @Log(title = "卫生检查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YxxSanitation yxxSanitation)
    {
        List<YxxSanitation> list = yxxSanitationService.selectYxxSanitationList(yxxSanitation);
        ExcelUtil<YxxSanitation> util = new ExcelUtil<YxxSanitation>(YxxSanitation.class);
        util.exportExcel(response, list, "卫生检查记录数据");
    }

    /**
     * 获取卫生检查记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sanitation:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(yxxSanitationService.selectYxxSanitationByRecordId(recordId));
    }

    /**
     * 新增卫生检查记录
     */
    @PreAuthorize("@ss.hasPermi('system:sanitation:add')")
    @Log(title = "卫生检查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YxxSanitation yxxSanitation)
    {
        return toAjax(yxxSanitationService.insertYxxSanitation(yxxSanitation));
    }

    /**
     * 修改卫生检查记录
     */
    @PreAuthorize("@ss.hasPermi('system:sanitation:edit')")
    @Log(title = "卫生检查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YxxSanitation yxxSanitation)
    {
        return toAjax(yxxSanitationService.updateYxxSanitation(yxxSanitation));
    }

    /**
     * 删除卫生检查记录
     */
    @PreAuthorize("@ss.hasPermi('system:sanitation:remove')")
    @Log(title = "卫生检查记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(yxxSanitationService.deleteYxxSanitationByRecordIds(recordIds));
    }
}
